package com.shangyueshang.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.shangyueshang.serializer.DeserializerBigDecimal;
import com.shangyueshang.serializer.SerializerBigDecimal;
import lombok.Data;

import java.math.BigDecimal;
import java.time.YearMonth;

/**
 * @author: JokeyZheng
 * @email: zhengjingfeng@ruqimobility.com
 * @created: 2022/1/20 17:58
 * @version: v1.0.0
 */
@Data
public class CompanyRevenue {

    /**
     * 交易月份
     */
    @JsonFormat(pattern = "yyyy-MM")
    private YearMonth tradeMonth;

    /**
     * 销量总收入，单位：元
     */
    @JsonSerialize(using = SerializerBigDecimal.class)
    @JsonDeserialize(using = DeserializerBigDecimal.class)
    private BigDecimal productSales;

    /**
     * 销量毛利润，单位：元
     */
    @JsonSerialize(using = SerializerBigDecimal.class)
    @JsonDeserialize(using = DeserializerBigDecimal.class)
    private BigDecimal saleRevenue;

    /**
     * 退款费用，单位：元
     */
    @JsonSerialize(using = SerializerBigDecimal.class)
    @JsonDeserialize(using = DeserializerBigDecimal.class)
    private BigDecimal returnFee;

    /**
     * 平台支出费用，单位：元
     */
    @JsonSerialize(using = SerializerBigDecimal.class)
    @JsonDeserialize(using = DeserializerBigDecimal.class)
    private BigDecimal platformSpendFee;

    /**
     * 固定成本，单位：元
     */
    @JsonSerialize(using = SerializerBigDecimal.class)
    @JsonDeserialize(using = DeserializerBigDecimal.class)
    private BigDecimal fixedCost;

    /**
     * 采购成本，单位：元
     */
    @JsonSerialize(using = SerializerBigDecimal.class)
    @JsonDeserialize(using = DeserializerBigDecimal.class)
    private BigDecimal purchaseFee;

    /**
     * 包装成本，单位：元
     */
    @JsonSerialize(using = SerializerBigDecimal.class)
    @JsonDeserialize(using = DeserializerBigDecimal.class)
    private BigDecimal packFee;

    /**
     * 预估头程运费，单位：元
     */
    @JsonSerialize(using = SerializerBigDecimal.class)
    @JsonDeserialize(using = DeserializerBigDecimal.class)
    private BigDecimal estimateHeadwayFee;

    /**
     * 实际头程运费，单位：元
     */
    @JsonSerialize(using = SerializerBigDecimal.class)
    @JsonDeserialize(using = DeserializerBigDecimal.class)
    private BigDecimal actualHeadwayFee;

    /**
     * 纯利润统计，单位：元
     *
     * @return
     */
    @JsonSerialize(using = SerializerBigDecimal.class)
    public BigDecimal getNetProfit() {
        return saleRevenue
                .add(returnFee)
                .add(platformSpendFee)
                .add(fixedCost)
                .add(purchaseFee)
                .add(packFee);
    }
}
